package com.jspgou.core.entity.base;

import com.jspgou.core.entity.*;
import java.io.Serializable;
import java.util.Set;

/**
 * This is an object that contains data related to the jo_authentication table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="jo_authentication"
 */

public abstract class BaseZone  implements Serializable{
	
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static String REF = "Zone";
    public static String PROP_RGT = "rgt";
    public static String PROP_WEBSITE = "website";
    public static String PROP_LFT = "lft";
    public static String PROP_PARENT = "parent";
    public static String PROP_ZIP = "zip";
    public static String PROP_NAME = "name";
    public static String PROP_ID = "id";

	// constructors
    public BaseZone() {
        initialize();
    }

	/**
	 * Constructor for primary key
	 */
    public BaseZone(Long id){
        this.setId(id);
        initialize();
    }

	/**
	 * Constructor for required fields
	 */
    public BaseZone(Long id, 
    		        
    		        Website website,
    		        String name, 
    		        Integer lft,
    		        Integer rgt) {
        this.setId(id);
        this.setWebsite(website);
        this.setName(name);
        this.setLft(lft);
        this.setRgt(rgt);
        initialize();
    }

    protected void initialize(){}

	private int hashCode = Integer.MIN_VALUE;
	
	// primary key
    private Long id;
    
	// fields
    private String name;
    private String zip;
    private Integer lft;
    private Integer rgt;
    private Website website;
    private Zone parent;
    private Set<Zone> zones;
    
    public Long getId(){
        return id;
    }

    public void setId(Long id){
        this.id = id;
		this.hashCode = Integer.MIN_VALUE;
    }

    public String getName(){
        return name;
    }

    public void setName(String name){
        this.name = name;
    }

    public String getZip(){
        return zip;
    }

    public void setZip(String zip){
        this.zip = zip;
    }

    public Integer getLft(){
        return lft;
    }

    public void setLft(Integer lft){
        this.lft = lft;
    }

    public Integer getRgt(){
        return rgt;
    }

    public void setRgt(Integer rgt){
        this.rgt = rgt;
    }


    public Website getWebsite(){
        return website;
    }

    public void setWebsite(Website website){
        this.website = website;
    }

    public Zone getParent(){
        return parent;
    }

    public void setParent(Zone parent){
        this.parent = parent;
    }

    public Set<Zone> getZones(){
        return zones;
    }

    public void setZones(Set<Zone> zones){
        this.zones = zones;
    }

    public boolean equals(Object obj){
        if(null == obj) return false;
        if(!(obj instanceof Zone)) return false;
        else{
            Zone zone = (Zone)obj;
           if(null == this.getId() || null == zone.getId()) return false;
           else return (this.getId().equals(zone.getId()));
        }
    }

    public int hashCode(){
        if(Integer.MIN_VALUE == hashCode){
            if(null == getId()) return super.hashCode();
            else{
               String hashStr = this.getClass().getName()+":"+this.getId().hashCode();
               this.hashCode = hashStr.hashCode();
            }
        }
        return this.hashCode;
    }

    public String toString(){
        return super.toString();
    }

}
